/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.star.modules.sys.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.star.modules.sys.entity.ShFloatWin;
import com.star.modules.sys.service.ShFloatWinService;

/**
 * 浮窗信息Controller
 * @author L
 * @version 2019-03-12
 */
@Controller
@RequestMapping(value = "${adminPath}/sys/shFloatWin")
public class ShFloatWinController extends BaseController {

	@Autowired
	private ShFloatWinService shFloatWinService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public ShFloatWin get(String id, boolean isNewRecord) {
		return shFloatWinService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("sys:shFloatWin:view")
	@RequestMapping(value = {"list", ""})
	public String list(ShFloatWin shFloatWin, Model model) {
		model.addAttribute("shFloatWin", shFloatWin);
		return "modules/sys/shFloatWinList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("sys:shFloatWin:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<ShFloatWin> listData(ShFloatWin shFloatWin, HttpServletRequest request, HttpServletResponse response) {
		Page<ShFloatWin> page = shFloatWinService.findPage(new Page<ShFloatWin>(request, response), shFloatWin); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("sys:shFloatWin:view")
	@RequestMapping(value = "form")
	public String form(ShFloatWin shFloatWin, Model model) {
		model.addAttribute("shFloatWin", shFloatWin);
		return "modules/sys/shFloatWinForm";
	}

	/**
	 * 保存浮窗信息
	 */
	@RequiresPermissions("sys:shFloatWin:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated ShFloatWin shFloatWin) {
		shFloatWinService.save(shFloatWin);
		return renderResult(Global.TRUE, "保存浮窗信息成功！");
	}
	
	/**
	 * 删除浮窗信息
	 */
	@RequiresPermissions("sys:shFloatWin:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(ShFloatWin shFloatWin) {
		shFloatWinService.delete(shFloatWin);
		return renderResult(Global.TRUE, "删除浮窗信息成功！");
	}
	
}